package com.whucke.im.handler;

import com.whucke.im.utils.StringUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 消息处理
 *
 * @author Zhang Peng
 * @since 2019/2/20 14:58
 */
public class MessageChannelHandler extends ChannelHandlerAdapter {

    private static final Logger logger = LoggerFactory.getLogger(MessageChannelHandler.class);

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        FullHttpResponse response = (FullHttpResponse) msg;
        ByteBuf content = response.content();
        System.out.println(StringUtil.transformToString(content));
    }

}
